"""
  Created by Amor on 2018-09-07
"""
from sqlalchemy import Column, Integer, String, Text, orm

from app.models.base import Base

__author__ = '骆杨'


class Book(Base):
    id = Column(Integer, primary_key=True, autoincrement=True)
    title = Column(String(50), nullable=False)
    author = Column(String(300), default='未名')
    binding = Column(String(20))
    publisher = Column(String(50))
    price = Column(String(20))
    pages = Column(String(10))
    pubdate = Column(String(20))
    isbn = Column(String(15), nullable=False, unique=True)
    summary = Column(Text())
    image = Column(String(50))

    @orm.reconstructor
    def __init__(self):

        self.fields = ['id', 'title', 'author', 'binding', 'publisher', 'price',
                       'pages', 'pubdate', 'isbn', 'summary', 'image']

